Skip to content

Scheduler - Replace action enum with onDone/onCancel callbacks in AppointmentPopup#33047

Open
aleksei-semikozov wants to merge 4 commits intoDevExpress:26_1from
aleksei-semikozov:scheduler-popup-callbacks
Open

Scheduler - Replace action enum with onDone/onCancel callbacks in AppointmentPopup#33047
aleksei-semikozov wants to merge 4 commits intoDevExpress:26_1from
aleksei-semikozov:scheduler-popup-callbacks

Conversation

@aleksei-semikozov
Copy link
Copy Markdown
Contributor

No description provided.

@aleksei-semikozov aleksei-semikozov self-assigned this Mar 26, 2026
@aleksei-semikozov aleksei-semikozov marked this pull request as ready for review April 2, 2026 12:27
@aleksei-semikozov aleksei-semikozov requested a review from a team as a code owner April 2, 2026 12:27
Copilot AI review requested due to automatic review settings April 2, 2026 12:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Scheduler’s AppointmentPopup integration to remove action-enum–driven behavior and instead delegate save behavior to a provided callback (plus new config-driven title/readOnly behavior).

Changes:

  • Replaced ACTION_TO_APPOINTMENT-based save branching in AppointmentPopup with a single config.onDone(...) callback.
  • Updated Scheduler popup invocations to pass onDone, title, and readOnly (while keeping legacy-form behavior on the legacy popup).
  • Refactored/expanded Jest tests and the popup test harness mock to validate callback invocation, title rendering, and read-only behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
packages/devextreme/js/__internal/scheduler/m_scheduler.ts Switches non-legacy popup usage to callback-based onDone flows and sets popup title/readOnly from scheduler context.
packages/devextreme/js/__internal/scheduler/appointment_popup/m_popup.ts Introduces AppointmentPopupConfig and replaces action-based save logic with config.onDone; uses config.title and config.readOnly.
packages/devextreme/js/__internal/scheduler/appointment_popup/appointment_popup.test.ts Updates tests to validate onDone, title rendering, and Save visibility under readOnly.
packages/devextreme/js/__internal/scheduler/__tests__/__mock__/create_appointment_popup.ts Updates the test factory to pass the new config shape (onDone/title/readOnly) into popup.show.

updateAppointment?: jest.Mock;
onDone?: jest.Mock;
title?: string;
readOnly?: boolean;
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateAppointmentPopupOptions no longer declares addAppointment / updateAppointment, but createAppointmentPopup still reads options.addAppointment and options.updateAppointment later in this file. This will cause a TypeScript error (properties do not exist on the options type). Either re-add these optional fields to the interface, or remove the reads and rely solely on onDone for test customization.

Suggested change
readOnly?: boolean;
readOnly?: boolean;
addAppointment?: jest.Mock;
updateAppointment?: jest.Mock;

Copilot uses AI. Check for mistakes.
Comment on lines +1558 to +1565
onDone: (newAppointment) => {
this.updateAppointment(rawAppointment, appointment.source);
return this.addAppointment(newAppointment);
},
title: messageLocalization.format('dxScheduler-editPopupTitle'),
readOnly: false,
isToolbarVisible: true,
};
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the non-legacy exclude-from-series popup config, readOnly is hard-coded to false. Previously, the popup became read-only for disabled appointments, and checkRecurringAppointment only guards allowUpdating (not disabled). Consider computing readOnly here the same way as the regular update flow (e.g., based on AppointmentAdapter(...).disabled and editing permissions) to avoid enabling edits for disabled occurrences.

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +32
export interface AppointmentPopupConfig {
onDone: (appointment: Record<string, unknown>) => PromiseLike<unknown>;
title: string;
readOnly: boolean;
isToolbarVisible?: boolean;
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title mentions replacing the action enum with onDone/onCancel callbacks, but the new AppointmentPopupConfig only adds onDone (no onCancel). Either add an onCancel callback to the config and wire it to the Cancel action, or adjust the PR title/scope so it matches the implemented API.

Copilot uses AI. Check for mistakes.
onDone: (appointment: Record<string, unknown>) => PromiseLike<unknown>;
title: string;
readOnly: boolean;
isToolbarVisible?: boolean;
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppointmentPopupConfig defines isToolbarVisible?, and call sites in m_scheduler.ts set it, but AppointmentPopup never reads this value (the only occurrence is the interface field). This is dead API surface and can confuse callers; either implement the flag (e.g., to control Done/Cancel toolbar items) or remove it from the config and stop passing it.

Suggested change
isToolbarVisible?: boolean;

Copilot uses AI. Check for mistakes.
@aleksei-semikozov aleksei-semikozov force-pushed the scheduler-popup-callbacks branch from 5c8b946 to 9c52ce8 Compare April 2, 2026 12:36
…adOnly in exclude-from-series, fix mock types
Copilot AI review requested due to automatic review settings April 2, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants